package com.agentframework.examples;

import com.agentframework.autoconfigure.AgentAutoConfiguration;
import com.agentframework.core.annotation.AgentScan;
import com.agentframework.examples.jinhua.JinhuaEnvironment;
import com.agentframework.examples.jinhua.JinhuaTool;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.model.deepseek.autoconfigure.DeepSeekChatAutoConfiguration;
import org.springframework.ai.dashscope.autoconfigure.DashscopeAiAutoConfiguration;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;

/**
 * 使用注解方式配置诈金花游戏测试类
 * @author wangjun
 */
@SpringBootTest(classes = { 
    AgentAutoConfiguration.class, 
    JinhuaGameTest2.JinhuaGameConfiguration.class, 
    DashscopeAiAutoConfiguration.class,
    DeepSeekChatAutoConfiguration.class 
},
properties = {
    "spring.ai.deepseek.api-key=${DEEPSEEK_API_KEY}",
    "spring.ai.deepseek.chat.options.temperature=0",
    "spring.ai.dashscope.api-key=${DASHSCOPE_API_KEY}",
    "spring.ai.mcp.client.enabled=false",
    "spring.ai.mcp.client.stdio.servers-configuration=classpath:mcp-servers.json"
})
class JinhuaGameTest2 {

    private static final Logger logger = LoggerFactory.getLogger(JinhuaGameTest2.class);

    @Resource
    private JinhuaEnvironment jinhuaEnvironment;

    @Test
    public void testJinhuaGame() {
        // 显式调用环境的run方法启动游戏
        jinhuaEnvironment.run();
        logger.debug("======game over");
    }

    @AgentScan("com.agentframework")
    @SpringBootConfiguration
    static class JinhuaGameConfiguration {
        @Bean
        public JinhuaTool jinhuaTool() {
            return new JinhuaTool();
        }
    }
} 